/*  1:   */ package org.intellij.plugins.relaxNG.xml.dom.impl;
/*  2:   */ 
/*  3:   */

import com.intellij.psi.xml.XmlAttributeValue;
import org.intellij.plugins.relaxNG.model.Define;
import org.intellij.plugins.relaxNG.model.resolve.DefinitionResolver;
import org.intellij.plugins.relaxNG.xml.dom.RngGrammar;
import org.intellij.plugins.relaxNG.xml.dom.RngRef;

import java.util.Set;

/*  4:   */
/*  5:   */
/*  6:   */
/*  7:   */
/*  8:   */
/*  9:   */
/* 10:   */
/* 11:   */
/* 12:   */ 
/* 13:   */ public abstract class RngRefImpl
/* 14:   */   extends RngDomElementBase
/* 15:   */   implements RngRef
/* 16:   */ {
/* 17:   */   public void accept(CommonElement.Visitor paramVisitor)
/* 18:   */   {
/* 19:35 */     paramVisitor.visitRef(this);
/* 20:   */   }
/* 21:   */   
/* 22:   */   public Define getPattern()
/* 23:   */   {
/* 24:39 */     XmlAttributeValue localXmlAttributeValue = getName().getXmlAttributeValue();
/* 25:40 */     if (localXmlAttributeValue == null) {
/* 26:40 */       return null;
/* 27:   */     }
/* 28:42 */     String str = getReferencedName();
/* 29:43 */     if (str == null) {
/* 30:44 */       return null;
/* 31:   */     }
/* 32:47 */     RngGrammar localRngGrammar = getScope();
/* 33:48 */     if (localRngGrammar == null) {
/* 34:49 */       return null;
/* 35:   */     }
/* 36:52 */     Set localSet = DefinitionResolver.resolve(localRngGrammar, str);
/* 37:   */     
/* 38:   */ 
/* 39:55 */     return (localSet != null) && (localSet.size() > 0) ? (Define)localSet.iterator().next() : null;
/* 40:   */   }
/* 41:   */   
/* 42:   */   protected RngGrammar getScope()
/* 43:   */   {
/* 44:59 */     return (RngGrammar)getParentOfType(RngGrammar.class, true);
/* 45:   */   }
/* 46:   */   
/* 47:   */   public String getReferencedName()
/* 48:   */   {
/* 49:63 */     return (String)getName().getValue();
/* 50:   */   }
/* 51:   */ }



/* Location:           E:\idea\

 * Qualified Name:     org.intellij.plugins.relaxNG.xml.dom.impl.RngRefImpl

 * JD-Core Version:    0.7.0.1

 */